package com.haixiaoke.saas.common.utils.TreeUtil;

import java.util.List;

/**
 * @author a
 */
public abstract class ITree<ID> {

    /**
     * id
     */
    protected ID id;

    /**
     * 父Id
     */
    protected ID parentId;

    /**
     * 排序字段（默认从小到大排序）
     */
    protected Integer sort = 0;

    /**
     * 所有的子集列表
     */
    protected List<ITree<ID>> children;

    public ITree(ID id, ID parentId, Integer sort, List<ITree<ID>> children) {
        this.id = id;
        this.parentId = parentId;
        this.sort = sort;
        this.children = children;
    }

    public ITree() {
    }

    public ID getId() {
        return id;
    }

    public void setId(ID id) {
        this.id = id;
    }

    public ID getParentId() {
        return parentId;
    }

    public void setParentId(ID parentId) {
        this.parentId = parentId;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public List<ITree<ID>> getChildren() {
        return children;
    }

    public void setChildren(List<ITree<ID>> children) {
        this.children = children;
    }

    /**
     * 是否是顶层
     *
     * @return boolean
     */
    protected abstract boolean firstLevel();
}
